﻿Public Class frmSociete

    Private szSQL As String
    Private rs As ADODB.Recordset

    Private Sub frmSociete_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        'Lire la SOCIETE par le Nom
        szSql = "CALL spGET_P_SOCIETE('" & gSocieteCode & "')"
        GetRecordset(ctDSN_DEVFAC, szSql, rs)
        If rs.RecordCount < 1 Then
            MsgBox("Table P_SOCIETE non trouvé ....")
            rs.Close()
            Exit Sub
        End If

        TE_CODE.Text = rs.Fields("societe").Value
        TE_NOM.Text = rs.Fields("nom").Value
        TE_ADRESSE.Text = rs.Fields("ADRESSE").Value
        TE_CP.Text = rs.Fields("CP").Value
        TE_VILLE.Text = rs.Fields("ville").Value
        TE_TEL.Text = rs.Fields("TEL").Value

        TE_C_NODOS.Text = rs.Fields("C_NODOS").Value
        TE_C_DERN.Value = rs.Fields("c_dern").Value

        TE_V_CODE.Text = rs.Fields("v_code").Value
        TE_B_CODE.Text = rs.Fields("B_Code").Value

        TE_Corresp1.Text = nv(rs.Fields("Corresp1").Value)
        TE_Corresp2.Text = nv(rs.Fields("Corresp2").Value)
        TE_Corresp3.Text = nv(rs.Fields("Corresp3").Value)
        TE_Corresp4.Text = nv(rs.Fields("Corresp4").Value)

        rs.Close()

    End Sub

    Private Sub BO_ENREGISTRER_Click(sender As System.Object, e As System.EventArgs) Handles BO_ENREGISTRER.Click
        If IsUserAuthorised(ctCompta) = False Then
            Exit Sub
        End If
        szSQL = "CALL spUPD_P_SOCIETE('" & gSocieteCode & "','" & TE_NOM.Text & "','" & TE_ADRESSE.Text & "','" & TE_CP.Text & "','" & _
          TE_VILLE.Text & "','" & TE_TEL.Text & "'," & TE_C_NODOS.Text & ",'','" & TE_V_CODE.Text & "','','','" & TE_B_CODE.Text & "','','','" & _
          nq(TE_Corresp1.Text) & "','" & nq(TE_Corresp2.Text) & "','" & nq(TE_Corresp3.Text) & "','" & nq(TE_Corresp4.Text) & "')"
        ExecQuery(ctDSN_DEVFAC, szSQL)
        Me.Close()

    End Sub
End Class